/*
 * Copyright (c) 2008-2013 Haulmont. All rights reserved.
 * Use is subject to license terms, see http://www.cuba-platform.com/license for details.
 */

package com.haulmont.asu.entity;

import com.haulmont.chile.core.annotations.Composition;
import com.haulmont.chile.core.annotations.MetaProperty;
import com.haulmont.chile.core.annotations.NamePattern;
import com.haulmont.cuba.core.entity.StandardEntity;

import javax.persistence.*;
import java.util.Set;

/**
 * Author: Sergey42
 * Date: 14.10.13 12:31
 */
@Table(name = "EXT_DIPLOMA_LEADER")
@Entity(name = "ext$DiplomaLeader")
@NamePattern("%s|name")
public class DiplomaLeader extends StandardEntity {

    private static final long serialVersionUID = -227987502823341134L;

    @ManyToOne
    @JoinColumn(name = "PERSON_ID")
    protected Person person;

    @Column(name = "IS_CATHEDRAL")
    protected Boolean isCathedral = Boolean.TRUE;

    @OneToMany(mappedBy = "diplomaLeader")
    @Composition
    protected Set<DiplomaProject> diplomaProjects;

    @MetaProperty
    public String getName() {
        return person != null ? person.getName() : "";
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public Boolean getIsCathedral() {
        return isCathedral;
    }

    public void setIsCathedral(Boolean cathedral) {
        isCathedral = cathedral;
    }

    public Set<DiplomaProject> getDiplomaProjects() {
        return diplomaProjects;
    }

    public void setDiplomaProjects(Set<DiplomaProject> diplomaProjects) {
        this.diplomaProjects = diplomaProjects;
    }
}
